package com.sf.leetcode.primary_alogrithm;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class primeNumber {

    public static void main(String[] args) {
        int arr[] = new int[100];
        List primeNumber = new ArrayList();
        List notPrimeNumber = new ArrayList();
        for (int i = 0; i< arr.length; i++){
            arr[i] = (int) (Math.random()*1000);
            if (isPrime(arr[i])){
                primeNumber.add(arr[i]);
            }else {
                notPrimeNumber.add(arr[i]);
            }
        }
        System.out.print("质数");
        for (Object o : primeNumber) {
            System.out.print(o+",");
        }
        System.out.println("非质数");
        for (Object o : notPrimeNumber) {
            System.out.print(o+",");
        }
    }

    public static boolean isPrime(int num){
        for (int i = 2; i < num; i++){
            if (num%i == 0){
                return false;
            }
        }
        return true;
    }
}
